home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xa;
-
- import com.extensibility.app.UI;
- import com.extensibility.util.Debug;
- import com.extensibility.xml.AttributeDeclaration;
- import com.extensibility.xml.BaseDeclaration;
- import com.extensibility.xml.DTDUtilities;
- import com.extensibility.xml.InternalPEDeclaration;
- import com.extensibility.xml.ParserException;
- import com.extensibility.xml.SchemaIntf;
- import com.extensibility.xml.URI;
- import com.extensibility.xml.dt.DataType;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import java.util.Vector;
-
- public class AggregateAttributeDecl extends BaseDeclaration implements Cloneable {
- Vector kids = new Vector();
- AttributeDeclaration globalAttr;
-
- public AggregateAttributeDecl(AttributeDeclaration var1) {
- super(((BaseDeclaration)var1).getName());
- this.addAttribute(var1);
- }
-
- public String getClassName() {
- return "com.extensibility.xml.AggregateAttributeDecl";
- }
-
- public void addAttribute(AttributeDeclaration var1) {
- this.kids.addElement(var1);
- if (var1.isGlobal()) {
- this.globalAttr = var1;
- }
-
- }
-
- public void removeAttribute(AttributeDeclaration var1) {
- this.kids.removeElement(var1);
- if (this.globalAttr == var1) {
- this.globalAttr = null;
- }
-
- }
-
- AttributeDeclaration getGlobal() {
- return this.globalAttr;
- }
-
- public AttributeDeclaration remove(String var1) {
- AttributeDeclaration var3 = null;
-
- int var2;
- for(var2 = this.kids.size() - 1; var2 >= 0; --var2) {
- var3 = (AttributeDeclaration)this.kids.elementAt(var2);
- if (var3.getOwner().getName().equals(var1)) {
- break;
- }
- }
-
- if (var2 < 0) {
- return null;
- } else {
- this.removeAttribute(var3);
- return var3;
- }
- }
-
- public String getFirstError() {
- Enumeration var1 = this.getAttributes();
-
- while(var1.hasMoreElements()) {
- AttributeDeclaration var2 = (AttributeDeclaration)var1.nextElement();
- String var3 = ((BaseDeclaration)var2).getFirstError();
- if (var3 != null) {
- if (this.isShared()) {
- return String.valueOf(String.valueOf(((BaseDeclaration)var2).getName()).concat(String.valueOf(" : "))).concat(String.valueOf(var3));
- }
-
- return var3;
- }
- }
-
- return null;
- }
-
- public Enumeration getAttributes() {
- return this.kids.elements();
- }
-
- public AttributeDeclaration getIndAttribute(int var1) {
- return (AttributeDeclaration)this.kids.elementAt(var1);
- }
-
- public int getAttributesSize() {
- return this.kids.size();
- }
-
- public Object clone() {
- AggregateAttributeDecl var1 = null;
-
- try {
- var1 = (AggregateAttributeDecl)super.clone();
- } catch (CloneNotSupportedException var3) {
- Debug.assert("Problem cloning AggregateAttributeDecl.", var3);
- }
-
- var1.kids = new Vector();
- Enumeration var2 = this.kids.elements();
-
- while(var2.hasMoreElements()) {
- var1.kids.addElement(((AttributeDeclaration)var2.nextElement()).clone());
- }
-
- return var1;
- }
-
- public AggregateAttributeDecl copyOf() {
- AggregateAttributeDecl var1 = null;
-
- try {
- var1 = (AggregateAttributeDecl)super.clone();
- } catch (CloneNotSupportedException var3) {
- Debug.assert("Problem cloning AggregateAttributeDecl.", var3);
- }
-
- var1.kids = new Vector();
-
- for(int var2 = 0; var2 < this.kids.size(); ++var2) {
- var1.kids.addElement(this.kids.elementAt(var2));
- }
-
- return var1;
- }
-
- private void DoToEach(Operation var1) {
- for(int var2 = 0; var2 < this.kids.size(); ++var2) {
- var1.performOperation((AttributeDeclaration)this.kids.elementAt(var2));
- }
-
- }
-
- public boolean contains(AttributeDeclaration var1) {
- return this.kids.indexOf(var1) >= 0;
- }
-
- public boolean contains(AttributeDeclaration.Owner var1) {
- for(int var2 = 0; var2 < this.kids.size(); ++var2) {
- if (var1.equals(this.getIndAttribute(var2).getOwner())) {
- return true;
- }
- }
-
- return false;
- }
-
- public void resetOwner() {
- this.DoToEach(new 1((AggregateAttributeDecl)null));
- }
-
- public void setOwner(SchemaDoc var1, String var2) {
- this.DoToEach(new 2(var1, var2, (AggregateAttributeDecl)null));
- }
-
- boolean nullEquals(Object var1, Object var2) {
- if (var1 == null) {
- return var2 == null;
- } else {
- return var2 == null ? false : var1.equals(var2);
- }
- }
-
- boolean nullEquals(Vector var1, Vector var2) {
- if (!this.nullEquals((Object)var1, (Object)var2)) {
- return false;
- } else if (var1 == null) {
- return true;
- } else if (var1.size() != var2.size()) {
- return false;
- } else {
- for(int var3 = 0; var3 < var1.size(); ++var3) {
- if (!var1.elementAt(var3).equals(var2.elementAt(var3))) {
- return false;
- }
- }
-
- return true;
- }
- }
-
- public void setDataType(DataType var1) {
- this.DoToEach(new 3(var1, this));
- }
-
- public void setRequired(boolean var1) {
- this.DoToEach(new 4(var1, (AggregateAttributeDecl)null));
- }
-
- public void setOptions(String var1) {
- this.DoToEach(new 5(var1, this));
- }
-
- public void setChoices(Vector var1) {
- this.DoToEach(new 6(var1, this));
- }
-
- public void setChoices(String var1) {
- try {
- Vector var2;
- if (var1.indexOf(",") >= 0) {
- var2 = DTDUtilities.parseNameList(var1, ',');
- } else if (var1.indexOf("|") > 0) {
- var2 = DTDUtilities.parseNameList(var1, '|');
- } else {
- var2 = DTDUtilities.parseNameList(var1, ' ');
- }
-
- this.setChoices(var2);
- } catch (ParserException var3) {
- Debug.assert(var3);
- }
-
- }
-
- public void setName(SchemaDoc var1, String var2) {
- this.DoToEach(new 7(var1, var2, (AggregateAttributeDecl)null));
- }
-
- public void putMetaProp(String var1, String var2) {
- this.DoToEach(new 8(var1, var2, (AggregateAttributeDecl)null));
- }
-
- public void appendMetaProp(String var1, String var2) {
- this.DoToEach(new 9(var1, var2, (AggregateAttributeDecl)null));
- }
-
- public Object getMetaProp(String var1) {
- return this.getFirst().getMetaProp(var1);
- }
-
- public void removeMetaProp(String var1) {
- this.DoToEach(new 10(var1, (AggregateAttributeDecl)null));
- }
-
- public String getMetaPropAsString(String var1) {
- return this.getFirst().getMetaPropAsString(var1);
- }
-
- public void putMetaPropList(String var1, String var2) {
- this.DoToEach(new 11(var1, var2, (AggregateAttributeDecl)null));
- }
-
- public void putMetaPropAttrs(String var1, Hashtable var2) {
- this.DoToEach(new 12(var1, var2, (AggregateAttributeDecl)null));
- }
-
- public void setDefault(String var1) {
- this.DoToEach(new 13(var1, (AggregateAttributeDecl)null));
- }
-
- public AttributeDeclaration getFirst() {
- return this.kids.size() > 0 ? (AttributeDeclaration)this.kids.firstElement() : null;
- }
-
- public String getOwnerName() {
- return !this.isShared() && this.getFirst() != null ? String.valueOf(this.getFirst().getOwner() instanceof InternalPEDeclaration ? "%" : "").concat(String.valueOf(this.getFirst().getOwner().getName())) : UI.getString("attr.shared", Integer.toString(this.kids.size()));
- }
-
- public AttributeDeclaration.Owner getOwner() {
- return this.getFirst() != null ? this.getFirst().getOwner() : null;
- }
-
- public String getName() {
- return this.getFirst() != null ? this.getFirst().getName() : new String("");
- }
-
- public URI getURI() {
- return this.getFirst() != null ? this.getFirst().getURI() : null;
- }
-
- public DataType getDataType() {
- return this.getFirst() != null ? this.getFirst().getDataType() : null;
- }
-
- public boolean getRequired() {
- return this.getFirst() != null ? this.getFirst().getRequired() : false;
- }
-
- public String getTypeForDisplay(SchemaIntf var1) {
- return this.getFirst() != null ? this.getFirst().getTypeForDisplay(var1) : new String("");
- }
-
- public String getCommentsAsString(String var1, String var2) {
- return this.getFirst() != null ? this.getFirst().getCommentsAsString(var1, var2) : new String("");
- }
-
- public Vector getChoices() {
- return this.getFirst() != null ? this.getFirst().getChoices() : new Vector();
- }
-
- public String getOptions() {
- return this.getFirst() != null ? this.getFirst().getOptions() : "";
- }
-
- public String getDefault() {
- return this.getFirst() != null ? this.getFirst().getDefault() : new String("");
- }
-
- public boolean isShared() {
- return this.kids.size() > 1;
- }
-
- public boolean isEnumeration() {
- return this.getFirst() != null ? this.getFirst().isEnumeration() : false;
- }
-
- public boolean isNotation() {
- return this.getFirst() != null ? this.getFirst().isNotation() : false;
- }
-
- public boolean equals(AttributeDeclaration var1) {
- return this.getFirst() != null ? this.getFirst().canAggregateWith(var1) : false;
- }
-
- public int compareTo(AttributeDeclaration var1) {
- return this.getFirst() != null ? this.getFirst().compareAttrTo(var1) : 1;
- }
-
- public String getSource() {
- return this.getFirst() != null ? this.getFirst().getSource() : new String("");
- }
-
- public String toString() {
- return this.getFirst() != null ? this.getFirst().getSource() : new String("");
- }
- }
-